#include <REGX52.H>
#include"LCD1602.h"
#include"AT24C02.h"
#include"I2C.h"
#include"Delay.h"
#include"key.h"
unsigned char keyn;
unsigned int num;

void main()
{
	LCD_Init();
	LCD_ShowNum(1,1,num,5);
 	while(1)
	{
		keyn=key();
		if(keyn==1)
		{
			num++;
			LCD_ShowNum(1,1,num,5);
		}
		if(keyn==2)
		{
			num--;
			LCD_ShowNum(1,1,num,5);
		}
		if(keyn==3)
		{
			WRITE_BITY(0,num%256);
			Delay(5);
			WRITE_BITY(1,num/256);
			Delay(5);
			LCD_ShowString(2,1,"WRITE OK");
			Delay(1000);
			LCD_ShowString(2,1,"        ");
		}
		if(keyn==4)
		{
			num=RCE_BITY(0);
			num|=RCE_BITY(1)<<8;
			LCD_ShowNum(1,1,num,5);
			LCD_ShowString(2,1,"READ OK ");
			Delay(1000);
			LCD_ShowString(2,1,"        ");
		}
	}
}